<template>
	<view class="u-page">
		<u-list @scrolltolower="scrolltolower">
			<u-list-item v-for="(item, index) in indexList" :key="index">
				<u-cell
					v-if="item.status==0"
					size="large"
					:title="item.noticeTitle"
					:label="dateFormatMinutes(item.updateTime)"
					@click="toNoticeDetail(item)"
					:titleStyle="{'font-size':'38rpx','text-overflow':'ellipsis','overflow':'hidden','white-space':'nowrap','width':'85%'}">
				</u-cell>
			</u-list-item>
		</u-list>
	</view>
</template>

<script>
	import { getNoticeList } from '@/api/home.js'
	import { strFormatMinutes } from '@/utils/format.js'
	export default {
		data() {
			return {
				indexList: [],
				pageNum: 1,
			}
		},
		onLoad() {
			this.getList()
		},
		methods: {
			dateFormatMinutes(value){
				return strFormatMinutes(value)
			},
			scrolltolower() {
				this.pageNum += 1
				this.getList()
			},
			async getList() {
				const {data} = await getNoticeList({pageNum:this.pageNum});
				if (data.code==200) {
					if(data.rows.length > 0){
						this.indexList = [...this.indexList,...data.rows]
					}
				}
			},
			toNoticeDetail(item){
				uni.navigateTo({
					url: "/pages/home/notice/noticeDetail?notice="+encodeURIComponent(JSON.stringify(item))
				})
			}
		}
	}
</script>

<style>
	.titleStyle {
		font-size: 440rpx;
	}
</style>
